package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.vo.request.*;
import com.zhijian.medical.entity.vo.response.*;
import com.zhijian.medical.service.*;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 二代测序主表 控制层
 *
 * @author HCG
 * @version 1.0
 * @date 2022-08-23 14:59:59
 */
@Slf4j
@Controller
@Api(tags = "二代测序")
public class NgsController {

    @Autowired
    private NgsService service;

    @Autowired
    private NgsSjpzqService ngsSjpzqService;

    @Autowired
    private NgsHszbqService ngsHszbqService;

    @Autowired
    private NgsWkzbq1Service ngsWkzbq1Service;

    @Autowired
    private NgsWkzbq2Service ngsWkzbq2Service;

    @Autowired
    private NgsWkzbq3Service ngsWkzbq3Service;

    @Autowired
    private NgsWkfjq1Service ngsWkfjq1Service;

    @Autowired
    private NgsWkfjq2Service ngsWkfjq2Service;

    @Autowired
    private NgsWkfjq3Service ngsWkfjq3Service;

    @Autowired
    private NgsCxqService ngsCxqService;

    @Autowired
    private NgsSjfxService ngsSjfxService;

    @Autowired
    private NgsWkfjq4Service ngsWkfjq4Service;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs")
    @ApiOperation("新增")
    public boolean insert(@RequestBody NgsSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.insert(param) != null;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/ngs/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/ngs/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody NgsSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.update(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/ngs/{id}")
    @ApiOperation("根据id查询")
    public NgsVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/page")
    @ApiOperation("分页查询")
    public Page<NgsVo> selectByCondition(@RequestBody(required = false) NgsSearchVo param) {
        if (param == null)
            param = NgsSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
     * 新增or修改试剂配制区（片段化反应液及末端修复加A反应液配制）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/sjpzq")
    @ApiOperation("新增or修改试剂配制区（片段化反应液及末端修复加A反应液配制）数据")
    public boolean saveOrUpdateNgsSjpzq(@RequestBody NgsSjpzqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsSjpzqService.saveOrUpdate(param);
    }

    /**
     * 查询试剂配制区（片段化反应液及末端修复加A反应液配制）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/sjpzq/{ngsId}")
    @ApiOperation("查询试剂配制区（片段化反应液及末端修复加A反应液配制）数据")
    public NgsSjpzqVo selectNgsSjpzqByNgsId(@PathVariable("ngsId") Long ngsId) {
        return ngsSjpzqService.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改核酸制备区数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/hszbq")
    @ApiOperation("新增or修改核酸制备区数据")
    public boolean saveOrUpdateNgsHszbq(@RequestBody NgsHszbqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsHszbqService.saveOrUpdate(param);
    }

    /**
     * 查询核酸制备区数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/hszbq/{ngsId}")
    @ApiOperation("查询核酸制备区数据")
    public NgsHszbqVo selectNgsHszbqByNgsIdId(@PathVariable("ngsId") Long ngsId) {
        return ngsHszbqService.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库制备区（片段化）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkzbq1")
    @ApiOperation("新增or修改文库制备区（片段化）数据")
    public boolean saveOrUpdateNgsWkzbq1(@RequestBody NgsWkzbq1SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkzbq1Service.saveOrUpdate(param);
    }

    /**
     * 查询文库制备区（片段化）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkzbq1/{ngsId}")
    @ApiOperation("查询文库制备区（片段化）数据")
    public NgsWkzbq1Vo selectNgsWkzbq1ByNgsId(@PathVariable("ngsId") Long ngsId) {
        return ngsWkzbq1Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改查询文库制备区 （末端修复&加A）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkzbq2")
    @ApiOperation("新增or修改查询文库制备区 （末端修复&加A）数据")
    public boolean saveOrUpdateNgsWkzbq2(@RequestBody NgsWkzbq2SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkzbq2Service.saveOrUpdate(param);
    }

    /**
     * 查询文库制备区 （末端修复&加A）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkzbq2/{ngsId}")
    @ApiOperation("查询文库制备区 （末端修复&加A）数据")
    public NgsWkzbq2Vo selectNgsWkzbq2ByNgsId(@PathVariable("ngsId") Long ngsId) {
        return ngsWkzbq2Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库制备区（接头连接）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkzbq3")
    @ApiOperation("新增or修改文库制备区（接头连接）数据")
    public boolean saveOrUpdateNgsWkzbq3(@RequestBody NgsWkzbq3SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkzbq3Service.saveOrUpdate(param);
    }

    /**
     * 查询文库制备区（接头连接）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkzbq3/{ngsId}")
    @ApiOperation("查询文库制备区（接头连接）数据")
    public NgsWkzbq3Vo selectNgsWkzbq3ByNgsId(@PathVariable("ngsId") Long ngsId) {
        return ngsWkzbq3Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库富集区（文库富集）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkfjq1")
    @ApiOperation("新增or修改文库富集区（文库富集）数据")
    public boolean saveOrUpdateNgsWkfjq1(@RequestBody NgsWkfjq1SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkfjq1Service.saveOrUpdate(param);
    }

    /**
     * 根据id查询
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkfjq1/{ngsId}")
    @ApiOperation("查询文库富集区（文库富集）数据")
    public NgsWkfjq1Vo selectNgsWkfjq1ByNgsId(@PathVariable("ngsId") Long ngsId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), ngsId);
        return ngsWkfjq1Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库富集区（DNA文库混合及杂交）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkfjq2")
    @ApiOperation("新增or修改文库富集区（DNA文库混合及杂交）数据")
    public boolean saveOrUpdateNgsWkfjq2(@RequestBody NgsWkfjq2SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkfjq2Service.saveOrUpdate(param);
    }

    /**
     * 查询文库富集区（DNA文库混合及杂交）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkfjq2/{ngsId}")
    @ApiOperation("查询文库富集区（DNA文库混合及杂交）数据")
    public NgsWkfjq2Vo selectNgsWkfjq2ById(@PathVariable("ngsId") Long ngsId) {
        return ngsWkfjq2Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库富集区（文库捕获）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkfjq3")
    @ApiOperation("新增or修改文库富集区（文库捕获）数据")
    public boolean saveOrUpdateNgsWkfjq3(@RequestBody NgsWkfjq3SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkfjq3Service.saveOrUpdate(param);
    }

    /**
     * 查询文库富集区（文库捕获）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkfjq3/{ngsId}")
    @ApiOperation("查询文库富集区（文库捕获）数据")
    public NgsWkfjq3Vo selectNgsWkfjq3ByNgsId(@PathVariable("ngsId") Long ngsId) {
        return ngsWkfjq3Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改文库富集区（捕获文库富集及pooling）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/wkfjq4")
    @ApiOperation("新增or修改文库富集区（捕获文库富集及pooling）数据")
    public boolean saveOrUpdateNgsWkfjq4(@RequestBody NgsWkfjq4SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsWkfjq4Service.saveOrUpdate(param);
    }

    /**
     * 查询文库富集区（捕获文库富集及pooling）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/wkfjq4/{ngsId}")
    @ApiOperation("查询文库富集区（捕获文库富集及pooling）数据")
    public NgsWkfjq4Vo selectNgsWkfjq4ById(@PathVariable("ngsId") Long ngsId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), ngsId);
        return ngsWkfjq4Service.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改测序区（上机测序）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/cxq")
    @ApiOperation("新增or修改测序区（上机测序）数据")
    public boolean saveOrUpdateNgsCxq(@RequestBody NgsCxqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsCxqService.saveOrUpdate(param);
    }

    /**
     * 查询测序区（上机测序）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/cxq/{ngsId}")
    @ApiOperation("查询测序区（上机测序）数据")
    public NgsCxqVo selectNgsCxqById(@PathVariable("ngsId") Long ngsId) {
        return ngsCxqService.selectVoByNgsId(ngsId);
    }

    /**
     * 新增or修改数据分析（测序室、数据室）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ngs/sjfx")
    @ApiOperation("新增or修改数据分析（测序室、数据室）数据")
    public boolean saveOrUpdateNgsSjfx(@RequestBody NgsSjfxSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return ngsSjfxService.saveOrUpdate(param);
    }

    /**
     * 查询数据分析（测序室、数据室）数据
     *
     * @param ngsId
     * @return
     */
    @Response
    @GetMapping("/ngs/sjfx/{ngsId}")
    @ApiOperation("查询数据分析（测序室、数据室）数据")
    public NgsSjfxVo selectNgsSjfxByNgsIdId(@PathVariable("ngsId") Long ngsId) {
        return ngsSjfxService.selectVoByNgsId(ngsId);
    }

}